package br.ufrj.xml.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author raPHael
 *
 */
public class MyConnection {

	private static Connection myConnection;
	
	public static final String DRIVER = "org.postgresql.Driver";
	public static final String URL = "jdbc:postgresql://localhost:5432/postgres";
	public static final String USERNAME = "postgres";
	public static final String SENHA = "postgres";
								
	public MyConnection() throws ClassNotFoundException, SQLException
	{
		Class.forName(DRIVER);
		myConnection = DriverManager.getConnection(URL, USERNAME, SENHA);
	}

	public Connection getMyConnection() {
		return myConnection;
	}

	public void setMyConnection(Connection conexao) {
		this.myConnection = conexao;
	}
	
	public static Connection getConnection(String url, String userName, String senha) throws ClassNotFoundException, SQLException{
		Class.forName(DRIVER);
		myConnection = DriverManager.getConnection(url, userName, senha);
		return myConnection;
	}
}
